package io.renren.modules.pms.service.impl;

import io.renren.modules.pms.entity.dto.ProductAttributeCateDTO;
import io.renren.modules.pms.service.ProductAttributeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.pms.dao.ProductAttributeCategoryDao;
import io.renren.modules.pms.entity.ProductAttributeCategoryEntity;
import io.renren.modules.pms.service.ProductAttributeCategoryService;

import javax.annotation.Resource;


@Service("productAttributeCategoryService")
public class ProductAttributeCategoryServiceImpl extends ServiceImpl<ProductAttributeCategoryDao, ProductAttributeCategoryEntity> implements ProductAttributeCategoryService {

    @Resource
    private  ProductAttributeCategoryDao productAttributeCategoryDao;

    @Autowired
    ProductAttributeService productAttributeService;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<ProductAttributeCategoryEntity> page = this.page(
                new Query<ProductAttributeCategoryEntity>().getPage(params),
                new QueryWrapper<ProductAttributeCategoryEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public boolean delete(Long id) {

        boolean delete = this.removeById(id);

        if (delete){

        }
        return false;
    }

    /**
     * 获取所有商品属性分类及其下属性
     */
    @Override
    public List<ProductAttributeCateDTO> getListWithAttr() {
        return productAttributeCategoryDao.getListWithAttr();
    }

}
